home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Software für Mac-OS X / Entwickler-Tools / netbeans / modules / ext / djava.jar / koala / dynamicjava / interpreter / modifier / VariableModifier.class (.txt) < prev   
Encoding:
Java Class File  |  2000-03-14  |  1.5 KB  |  32 lines

  1. package koala.dynamicjava.interpreter.modifier;
  2.  
  3. import koala.dynamicjava.interpreter.context.Context;
  4. import koala.dynamicjava.interpreter.error.CatchedExceptionError;
  5. import koala.dynamicjava.tree.QualifiedName;
  6. import koala.dynamicjava.tree.visitor.Visitor;
  7.  
  8. public class VariableModifier extends LeftHandSideModifier {
  9.    protected QualifiedName name;
  10.    protected Class type;
  11.    protected String representation;
  12.  
  13.    public Object prepare(Visitor var1, Context var2) {
  14.       return var2.get(this.representation);
  15.    }
  16.  
  17.    public void modify(Context var1, Object var2) {
  18.       if (!this.type.isPrimitive() && var2 != null && !this.type.isAssignableFrom(var2.getClass())) {
  19.          ClassCastException var3 = new ClassCastException(this.representation);
  20.          throw new CatchedExceptionError(var3, this.name);
  21.       } else {
  22.          var1.set(this.representation, var2);
  23.       }
  24.    }
  25.  
  26.    public VariableModifier(QualifiedName var1, Class var2) {
  27.       this.name = var1;
  28.       this.type = var2;
  29.       this.representation = var1.getRepresentation();
  30.    }
  31. }
  32.